package com.azkj.album.view.widgets;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.azkj.album.R;


public class TitleNavBar extends RelativeLayout {

    private Context mContext;
    private View root;
    private TextView titleTv, rightTv, rightTv2;
    private ImageView leftIv, rightIv;


    public TitleNavBar(Context context) {
        super(context);
        init(context);
    }

    public TitleNavBar(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    private void init(Context context) {
        this.mContext = context;
        root = View.inflate(context, R.layout.layout_nav_bar, this);
        titleTv = root.findViewById(R.id.tv_action_bar_title);
        leftIv = root.findViewById(R.id.iv_actionbar_left);
        rightIv = root.findViewById(R.id.iv_actionbar_right);
        rightTv = root.findViewById(R.id.tv_actionbar_right);
        rightTv2 = root.findViewById(R.id.tv_actionbar_right_2);

    }


    public void setTitle(String title) {
        titleTv.setText(title);
    }

    public void setRightTitle(String title) {
        rightTv.setText(title);
        rightTv.setVisibility(VISIBLE);
    }

    public TextView getRightTv() {
        return rightTv;
    }

    public TextView getTitleTv() {
        return titleTv;
    }

    public TextView getRightTv2() {
        return rightTv2;
    }

    public ImageView getRightIv() {
        return rightIv;
    }

    public ImageView getLeftIv() {
        return leftIv;
    }


    public void setLeftListener(OnClickListener listener) {
        leftIv.setOnClickListener(listener);

    }

    public void setRightListener2(OnClickListener listener) {
        rightTv2.setOnClickListener(listener);
        rightTv2.setVisibility(VISIBLE);

    }

    public void setRightResource(int id) {
        rightIv.setImageResource(id);
        rightIv.setVisibility(VISIBLE);
    }

}
